package day20170411.homework.student.client;



import java.util.Scanner;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import day20170411.homework.student.dao.StudentDao;
import day20170411.homework.student.entity.StudentEntity;
import utils.ArrayUtil;


public class StudentEntityTest {
	
	/**
	 *  实例化一个StudentEntity数组
	 */
	private StudentEntity[] stuArrays = new StudentEntity[5];
	
	/**
	 *  实例化一个StudentEntity对象
	 */
	private StudentEntity stuObject = new StudentEntity();
	
	private Scanner scanner = null;
	
	private StudentDao dao = new StudentDao();
	
	@Test
	public void testName() throws Exception {
		
	}
	
	
	/**
	 * 成绩不合格的人测试
	 * @throws Exception
	 */
	@Test
	public void findAllFailTest() throws Exception {
		StudentEntity[] findAllFail = dao.findAllFail(stuArrays);
		ArrayUtil.arrayPrint(findAllFail);
	}
	
	/**
	 * 成绩个位数为6的
	 * @throws Exception
	 */
	@Test
	public void finAllGe() throws Exception {
		StudentEntity[] findAllGe = dao.findAllGe(stuArrays, 6);
		ArrayUtil.arrayPrint(findAllGe);
	}
	
	/**
	 * 在所有方法执行前执行
	 * @throws Exception
	 */
	@Before
	public void before() throws Exception {
		//第一位学生
		stuObject.setName("贾梦菊");
		stuObject.setIdCard("123456789111111111");
		stuObject.setAge(20);
		stuObject.setScore(66);
		stuObject.setSex('女');
		stuArrays[0] = stuObject;
		stuObject = new StudentEntity();
		
		//第二位学生
		stuObject.setName("张嘉源");
		stuObject.setIdCard("123456789111111112");
		stuObject.setAge(21);
		stuObject.setScore(76);
		stuObject.setSex('男');
		stuArrays[1] = stuObject;
		stuObject = new StudentEntity();
		
		//第三位学生
		stuObject.setName("何小强");
		stuObject.setIdCard("123456789111111113");
		stuObject.setAge(28);
		stuObject.setScore(86);
		stuObject.setSex('男');
		stuArrays[2] = stuObject;
		stuObject = new StudentEntity();
		
		//第四位学生
		stuObject.setName("靳志辉");
		stuObject.setIdCard("123456789111111114");
		stuObject.setAge(25);
		stuObject.setScore(45);
		stuObject.setSex('男');
		stuArrays[3] = stuObject;
		
		scanner = new Scanner(System.in);
	}
	
	/**
	 * 在所有方法执行完后执行
	 * @throws Exception
	 */
	@After
	public void after() throws Exception {
		scanner.close();
	}
}
